#include "SingleApplication.h"

CSingleApplication::CSingleApplication(int &argc, char **argv) :QApplication(argc, argv, true)
{
    singular_ = new QSharedMemory("_ZHILAIBOX_", this);
}

CSingleApplication::~CSingleApplication()
{
	if (singular_->isAttached())
		singular_->detach();
}

bool CSingleApplication::Lock()
{
	if (singular_->attach(QSharedMemory::ReadOnly)) {
		singular_->detach();
		return false;
	}

	if (singular_->create(1))
		return true;

	return false;
}
